package com.android.microweather;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class SettingsActivity extends PreferenceActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.settings);
		
		// Set Units summary dynamically
/*		String unitsKey = getString(R.string.settings_units_key);
		String unitsValue = PreferenceManager.getDefaultSharedPreferences(this).
						getString(unitsKey, null);*/

		ListPreference unitsPref = (ListPreference)
			getPreferenceManager().findPreference(getString(R.string.settings_units_key));
		unitsPref.setSummary(unitsPref.getEntry());
		
		PreferenceManager.getDefaultSharedPreferences(this).
				registerOnSharedPreferenceChangeListener(
						new SharedPreferences.OnSharedPreferenceChangeListener() {
							public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
																  String key) {
								ListPreference unitsPref = (ListPreference)
										getPreferenceManager().findPreference(getString(R.string.settings_units_key));
								unitsPref.setSummary(unitsPref.getEntry());
							}
						}
						);
	}

}
